package main

import (
	"fmt"
)

func workerCsp(id int, c chan int, done chan bool) {
	for n := range c {
		fmt.Printf(" Worker %d received %d\n", id, n)
		done <- true
	}
}

type Worker struct {
	in   chan int
	done chan bool
}

func createWorkerCsp(id int) Worker {
	w := Worker{
		in:   make(chan int),
		done: make(chan bool),
	}
	go workerCsp(id, w.in, w.done)
	return w
}
func main() {
	var wowkers [10]Worker
	for i := 0; i < 10; i++ {
		wowkers[i] = createWorkerCsp(i)
	}
	for i := 0; i < 10; i++ {
		wowkers[i].in <- 'A'
		//<-wowkers[i].done
	}
	for _, worker := range wowkers {
		<-worker.done
	}
	for i := 0; i < 10; i++ {
		wowkers[i].in <- 'B'
		//<-wowkers[i].done
	}
	for _, worker := range wowkers {
		<-worker.done
	}
}
